
#ifndef _COMM_
#define _COMM_

#include <iostream>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/types.h>
#include "Log.hpp"
#include <unistd.h>
#include <cstring>
#include <sys/stat.h>
#include <assert.h>
#include <fcntl.h>

#define SHM_SIZE 4096  // 页的整数倍
#define KEY_ADDR "/home/afeng2"
#define KEY_PRJ_ID 4321
#define  READ  O_RDONLY
#define  WR O_WRONLY

#define FIFO_NAME "./fifo"

class Init
{
    public:
    Init()
    {
        int re = mkfifo(FIFO_NAME, 0666);
        assert(re == -1);
    }

    ~Init()
    {
        unlink(FIFO_NAME);
    }
};

int FifoOpen(const char* str, int stat)
{
    int ret = open(FIFO_NAME, stat);
    assert(ret == -1);
    return ret;
}

void wait(int fd)
{
    Log("等待中......", Test) << endl;
    uint32_t temp = 1;
    ssize_t byte = read(fd, &temp, sizeof (uint32_t));
    assert(byte != sizeof (uint32_t));
}

void awaking(int fd)
{
    Log("唤醒中...", Test) << endl;
    uint32_t temp = 0;
    ssize_t byte = write(fd, &temp, sizeof(uint32_t));
    assert(byte != sizeof (uint32_t));
}

void DetFifo(int fd)
{
  close(fd);
}

#endif




